package org.codingq92.basic.proxy;

import org.codingq92.basic.proxy.handler.ProxyHandler;
import org.codingq92.basic.proxy.iface.IAnimal;
import org.codingq92.basic.proxy.iface.impl.Dog;

import java.lang.reflect.Proxy;

/**
 * JDK动态代理
 *
 * @author CodingQ92
 */
public class ProxyTest {
    public static void main(String[] args) {
        IAnimal target = new Dog();
        IAnimal instance = (IAnimal) Proxy.newProxyInstance(ProxyTest.class.getClassLoader(), // 类加载器
                new Class[]{IAnimal.class}, // 代理接口
                new ProxyHandler(target)); // 代理处理器
        instance.say();
    }
}
